﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using TrainingManagement.api.Models.BusinessLogic;
using TrainingManagement.api.Models.BusinessLogic.Employee;
using TrainingManagement.api.Models.BusinessObjects;
using TrainingManagement.api.Models.BusinessObjects.Responses;
using Provausio.Common.Utility.Extensions;

namespace TrainingManagement.api.Controllers
{
    public class EmployeeController : ApiController
    {
        [System.Web.Http.ActionName("Create")]
        public Employee PutEmployee([FromBody] Employee employee)
        {
            return new EmployeeCreateOperation().Run(employee);
        }

        [System.Web.Http.ActionName("Update")]
        public void PostUpdateEmployee([FromBody] Employee employee)
        {
            new EmployeeUpdateOperation().Run(employee);
        }

        [System.Web.Http.ActionName("Get")]
        public List<Employee> GetEmployee(int? employeeId)
        {
            return new EmployeeSelectOperation().Run(employeeId);
        }

        [System.Web.Http.ActionName("DeactivateEmployee")]
        public void DeleteDeactivateEmployee(string employeeId)
        {
            //Deactivates, but does not delete
            var id = employeeId.ToType<int>();
            new EmployeeDeactivateOperation().Run(id);
        }

        [System.Web.Http.ActionName("ReactivateEmployee")]
        public void PostReactivateEmployee([FromUri] string employeeId)
        {
            var id = employeeId.ToType<int>();
            new EmployeeReactivateOperation().Run(id);
        }
    }
}
